package models

import "gorm.io/gorm"

// 订单表
type Order struct {
	gorm.Model
	UserId  int64   `gorm:"type:int;index;not null;commit:'用户Id'"`
	OrderSn string  `gorm:"type:char(36);not null;commit:'用户Id'"`
	Amount  float64 `gorm:"type:decimal(10,2);not null;commit:'订单金额'"`
	Status  int     `gorm:"type:int;default:0;not null;commit:'订单状态:0未支付,1-已支付,2-已取消,3-完成'"`
	PayType int     `gorm:"type:int;default:0;not null;commit:'支付方式:0支付宝,1-微信'"`
}

// 订单商品表
type OrderGoods struct {
	gorm.Model
	OrderId    int
	GoodsId    int
	GoodsTitle string
	GoodsNum   int
	GoodsPrice float64
}

func (o *Order) Create(db *gorm.DB) error {
	return DB.Create(&o).Error
}
func (og *OrderGoods) Create(db *gorm.DB) error {
	return DB.Create(&og).Error
}
